package br.sed.theenemy.model.bean;


import java.util.Calendar;
import java.util.Date;

import br.sed.theenemy.business.utils.Utils;

/**
 * 
 * @author Paulo Mendes
 * @email paulo.mendes87@gmail.com
 * 
 * This class is a bean of user request. Used to register an unser on the datbase.
 *
 */
public class UserRequest {
	private String firstName;
	private String lastName;
	private String email;
	private String hash;
	private String gender;
	private Date bornDate;
	private String pass;
	private Date registerDate;
		
	
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;

		Calendar now = Calendar.getInstance();
		this.hash = Utils.MD5(email + now.getTimeInMillis());
	}
	public String getHash() {
		return hash;
	}
	public void setHash(String hash) {
		this.hash = hash;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	
	public void setPass(String pass){
		this.pass = pass;
	}
	public void setPass(String pass1, String pass2) throws Exception {
		if(pass1.isEmpty() || pass2.isEmpty()){
			throw new Exception("Você precisa Password");
		}		
		else if(!pass1.equals(pass2)){
			throw new Exception("Erro no Password.");
		}
		else{
			this.pass = Utils.MD5(pass1);
		}
	}
	public String getPass() {
		return pass;
	}
	public void setRegisterDate(Date registerDate) {
		this.registerDate = registerDate;
	}
	public Date getRegisterDate() {
		return registerDate;
	}
	public Date getBornDate() {
		return bornDate;
	}
	public void setBornDate(Date bornDate) {
		this.bornDate = bornDate;
	}
	
}
